﻿using System.Collections.ObjectModel;
using KPIS.GERP.Models.FIM;
using KPIS.GERP.Models.HRM;
using KPIS.GERP.Models.ICM;
using KPIS.GERP.Models.SYS;
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;

namespace KPIS.GERP.Models.Migrations
{
    public partial class Configuration
    {
        public void SeedSYS(GERPContext context)
        {

            context.Users.AddOrUpdate(new User { UserId = 1, EmpId = 1, Code = "administrator", Password = "p@ssw0rd", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = 1, UpdatedWhen = DateTime.Now, RecordStatus = "U", IsAdmin = true});
            context.Users.AddOrUpdate(new User { UserId = 2, EmpId = 5, Code = "3449900331177", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = 1, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            if (context.Users.Find(3) != null) context.Users.Remove(context.Users.Find(3));   // context.Users.AddOrUpdate(new User {UserId = 3, EmpId = 0, Code = "3180600570065", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = 1, UpdatedWhen = DateTime.Now, RecordStatus = "D"});
            if (context.Users.Find(4) != null) context.Users.Remove(context.Users.Find(4));   // context.Users.AddOrUpdate(new User {UserId = 4, EmpId = 7, Code = "3149900118620", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = 1, UpdatedWhen = DateTime.Now, RecordStatus = "D"});
            context.Users.AddOrUpdate(new User { UserId = 5, EmpId = 23, Code = "3540400523531", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = 1, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 6, EmpId = 4, Code = "3709900326146", Password = "57", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = 4, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 7, EmpId = 2, Code = "3301000417729", Password = "1668", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = 2, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 8, EmpId = 20, Code = "0001", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            if (context.Users.Find(9) != null) context.Users.Remove(context.Users.Find(9));   //context.Users.AddOrUpdate(new User {UserId = 9, EmpId = 21, Code = "0002", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = 1, UpdatedWhen = DateTime.Now, RecordStatus = "D"});
            context.Users.AddOrUpdate(new User { UserId = 10, EmpId = 8, Code = "1101400232110", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 11, EmpId = 7, Code = "3100100984049", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 12, EmpId = 10, Code = "3120600676629", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 13, EmpId = 11, Code = "1720900039568", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 14, EmpId = 12, Code = "3330500816184", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 15, EmpId = 13, Code = "3120101305544", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            if (context.Users.Find(16) != null) context.Users.Remove(context.Users.Find(16));
            context.Users.AddOrUpdate(new User { UserId = 17, EmpId = 16, Code = "1309800015481", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 18, EmpId = 15, Code = "3100202807316", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = 1, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 19, EmpId = 17, Code = "3360700067916", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 20, EmpId = 18, Code = "3700700159396", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 21, EmpId = 19, Code = "3160100073585", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            if (context.Users.Find(22) != null) context.Users.Remove(context.Users.Find(22));
            context.Users.AddOrUpdate(new User { UserId = 23, EmpId = 22, Code = "3100100621485", Password = "zz2we75", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = 22, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 24, EmpId = 43, Code = "3101401224991", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 25, EmpId = 44, Code = "5302100124534", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 26, EmpId = 24, Code = "3250400015326", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 27, EmpId = 32, Code = "3101700728001", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 28, EmpId = 27, Code = "3900800180620", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 29, EmpId = 33, Code = "3700700239179", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 30, EmpId = 31, Code = "3320700772661", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 31, EmpId = 37, Code = "3760600377235", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 32, EmpId = 41, Code = "3100203310261", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 33, EmpId = 46, Code = "3410601198469", Password = "ors4c5u", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = 46, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 34, EmpId = 42, Code = "3100203459788", Password = "1379", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = 42, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 35, EmpId = 45, Code = "3720400647590", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 36, EmpId = 28, Code = "3130500313117", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 37, EmpId = 40, Code = "3700200255183", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 38, EmpId = 47, Code = "3190400138160", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 39, EmpId = 29, Code = "3100701042536", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 40, EmpId = 35, Code = "4579900002375", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 41, EmpId = 30, Code = "3700700475425", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 42, EmpId = 38, Code = "3240800120755", Password = "1605", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = 38, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 43, EmpId = 39, Code = "3160100073593", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 44, EmpId = 34, Code = "3369900131047", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 45, EmpId = 25, Code = "3660700236677", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 46, EmpId = 26, Code = "1360100081733", Password = "0000", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 47, EmpId = 48, Code = "3149900118620", Password = "9999", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = 48, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 48, EmpId = 36, Code = "3110102155155", Password = "wa3r1a", CreatedBy = 20, CreatedWhen = DateTime.Now, UpdatedBy = 36, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 49, EmpId = 6, Code = "3180600570065", Password = "5343", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = 6, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 50, EmpId = 67, Code = "3650101157931", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 51, EmpId = 72, Code = "3459900186045", Password = "pkrit-caew", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = 72, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 52, EmpId = 69, Code = "1100200282546", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 53, EmpId = 65, Code = "1509900193320", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 54, EmpId = 68, Code = "3120200339668", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 55, EmpId = 64, Code = "1160100047731", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 56, EmpId = 53, Code = "3101501776481", Password = "3343", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = 53, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 57, EmpId = 52, Code = "3140100561016", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 58, EmpId = 54, Code = "3700100040339", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 59, EmpId = 56, Code = "1101400637373", Password = "b47026291", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = 56, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 60, EmpId = 57, Code = "3180600512553", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 61, EmpId = 55, Code = "5720199008234", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 62, EmpId = 51, Code = "3869900003320", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 63, EmpId = 58, Code = "3309900484926", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 64, EmpId = 59, Code = "3330800588128", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 65, EmpId = 62, Code = "3120101213518", Password = "4385", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = 62, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 66, EmpId = 61, Code = "3850400110013", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            if (context.Users.Find(67) != null) context.Users.Remove(context.Users.Find(67));   //context.Users.AddOrUpdate(new User {UserId = 67, EmpId = 49, Code = "1010101010101", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U"});
            context.Users.AddOrUpdate(new User { UserId = 68, EmpId = 60, Code = "5102000045642", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 69, EmpId = 63, Code = "1101401353701", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 70, EmpId = 66, Code = "3720400013922", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 71, EmpId = 70, Code = "3520100484654", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 72, EmpId = 71, Code = "3159800066474", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 73, EmpId = 73, Code = "1100701328671", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 74, EmpId = 77, Code = "3461000088678", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 75, EmpId = 76, Code = "3101700528339", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 76, EmpId = 78, Code = "3260100095987", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 77, EmpId = 79, Code = "3120100327269", Password = "891817218", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = 79, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 78, EmpId = 80, Code = "3101800120871", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });
            context.Users.AddOrUpdate(new User { UserId = 79, EmpId = 81, Code = "1101499094750", Password = "0000", CreatedBy = 1, CreatedWhen = DateTime.Now, UpdatedBy = null, UpdatedWhen = DateTime.Now, RecordStatus = "U" });

            context.YearTypes.AddOrUpdate(new SYS.YearType{YearTypeId = 1,YearTypeName = "ปีงบประมาณ",RecordStatus = "U",CreatedBy = 1,CreatedWhen = DateTime.Now});
            context.YearTypes.AddOrUpdate(new SYS.YearType{YearTypeId = 2,YearTypeName = "ปฎิทิน",RecordStatus = "U",CreatedBy = 1,CreatedWhen = DateTime.Now});
        }
    }
}
